package dropOffDesk;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class DeskGUI extends JPanel {


	/**
	 * JPanel containing the collection of DropOfDesks
	 */
	private static final long serialVersionUID = -7923142236786360034L;
	private JPanel graphicPanel;
	private JScrollPane scrollPane = new JScrollPane();

	public DeskGUI(int numberOfDesks) {
		this.setSize(425, 790);
		
		this.setBorder(BorderFactory.createEmptyBorder(80,
				0, 0, 0));

		GridLayout gridLayout = new GridLayout(numberOfDesks, 1);

		graphicPanel = new JPanel(gridLayout);
		graphicPanel.setSize(450, numberOfDesks * 265);
		graphicPanel.setBackground(Color.WHITE);

		this.add(createScrollPane());

		setVisible(true);

	}

	public void addDeskPanel(DeskPanel panel, int deskOrdinal) {

		graphicPanel.add(panel);
		repaint();
		validate();

	}

	// create the panel to display the desks
	private JScrollPane createScrollPane() {

		scrollPane = new JScrollPane(graphicPanel);
		scrollPane.setPreferredSize(new Dimension(450, 805));
		scrollPane
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		return scrollPane;

	}

}
